package com.llseven.ai.spring.llseven.controller;

import com.llseven.ai.spring.llseven.enumtype.ModelType;
import com.llseven.ai.spring.llseven.service.BailianChatService;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.web.bind.annotation.*;



/**
 * @author ywb
 * @date 2025-04-11 16:20
 */
@RestController
@RequestMapping ("/ai")
public class AiController {

    private final BailianChatService bailianChatService;
    private final ChatClient chatClient;

    public AiController(ChatClient.Builder chatClientBuilder, BailianChatService bailianChatService) {
        this.chatClient = chatClientBuilder.build();
        this.bailianChatService = bailianChatService;
    }

    @GetMapping ("/chat")
    public String chat(@RequestParam(value = "message", defaultValue = "给我讲个笑话") String message) {

        return bailianChatService.chat(message);
    }

    @GetMapping("/generate-image")
    public String generateImage(
        @RequestParam(defaultValue = "一只坐着的橘黄色的猫，表情愉悦，活泼可爱，逼真准确", value = "prompt") String prompt,
        @RequestParam(defaultValue = "在原始纽扣基础上加工的工业纽扣，结构不变，不放大本体尺寸，允许新增孔或放大孔径，保留原有孔位，采用90度垂直切割方式，允许进行喷漆或电镀上色处理，真实材质，工业制造风格，高清特写，真实光照，边缘清晰，细节精致\n", value = "negativePrompt") String negativePrompt,
        @RequestParam(defaultValue = "https://nykj.senda360.com/image/goods/default/228121.jpg", value = "refImgUrl") String refImgUrl
    ) {
        return bailianChatService.create(
            ModelType.WANX_V1,
            prompt,
            negativePrompt,
            refImgUrl,
            0.35
        );
    }

    @GetMapping("/get-image")
    public String getImage(
        @RequestParam(value = "taskId") String taskId
    ) {
        return bailianChatService.query(taskId);
    }
}
